package org.example.ThreadDemo;

public class MyThread extends Thread {
    volatile boolean flag = false ;     // 线程执行的退出标记
    @Override
    public void run() {
        while(!flag) {
            System.out.println("MyThread...run...");
            try {
                Thread.sleep(3000);
//                wait(1000);
                System.out.println("MyThread...run...mmmmmmmmmmmm");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args) throws InterruptedException {

        // 创建MyThread对象
        MyThread t1 = new MyThread() ;
        t1.start();
        // 主线程休眠6秒
        Thread.sleep(6000);

        // 更改标记为true
        t1.flag = true ;

        String name="adcx";
        System.out.println(name.hashCode());
    }
}